DBG ?= -DMPI_ENDBG -DRUN_ENDBG -DBIT_ENDBG -DSEQ_ENDBG
CC = gcc
CFLAGS = -O3 -Wall -Wpedantic -lrt -g $(DBG)
OBJECTS = bitonic.o
 
all: run seq openmp cilk

%.o: %.c
	$(CC) $(CFLAGS) -c -o $@ $<

run: run.o
	$(CC) $(CFLAGS) -o $@ $^

seq: $(OBJECTS) bitonic_seq.o
	$(CC) $(CFLAGS) -o $@ $^

openmp: CFLAGS += -fopenmp
openmp: $(OBJECTS) bitonic_openmp.o
	$(CC) $(CFLAGS) -o $@ $^

cilk: CFLAGS += -fcilkplus
cilk: $(OBJECTS) bitonic_cilk.o
	$(CC) $(CFLAGS) -o $@ $^

mpi: CC = mpicc
ifeq ($(shell uname -n),jupiter.par.tuwien.ac.at)
mpi: CFLAGS := $(filter-out -Wpedantic -Wall -g,$(CFLAGS)) -D_POSIX_C_SOURCE=199309L -std=c99
	#module load mpi/openmpiS
endif
mpi: run_mpi.o bitonic_mpi.o
	$(CC) $(CFLAGS) -o $@ $^

saturn: clean
	scp * saturn:~/parcomp

jupiter: clean
	scp * jupiter:~/parcomp

clean:
	rm -f *.o openmp cilk mpi seq run
